package online.wenmeng.controller;

import online.wenmeng.exception.ParameterErrorException;
import online.wenmeng.service.AdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpSession;
import java.util.Map;

/**
 * 管理员管理界面
 */

@RestController
public class AdminController {

    @Autowired
    private AdminService adminService;
    
    /**
     * 查看全部用户
     */
    @RequestMapping("findAllUser")
    private Map<String,Object> adminFindAllUser(HttpSession session){
        return adminService.findAllUser();
    }

    /**
     * 删除用户
     */
    @RequestMapping("delUser/{userId}")
    private Map<String,Object> adminDelUser(HttpSession session,@PathVariable("userId") int userId){

        return adminService.delUser(userId);
    }

    /**
     * 删除电影
     */
    @RequestMapping("delMovie/{movieId}")
    private Map<String,Object> adminDelMovie(HttpSession session,@PathVariable("movieId") int movieId){
        return adminService.delMovie(movieId);
    }
    /**
     * 删除电影评论
     */
    @RequestMapping("delComments/{commentsId}")
    private Map<String,Object> adminDelComments(HttpSession session,@PathVariable("commentsId") int commentsId) throws ParameterErrorException {
        return adminService.delComments(commentsId);
    }

    /**
     * 查询电影所有评论
     * @return
     */
    @RequestMapping("findAllComments/{movieId}")
    private Map<String,Object> findAllComments(@PathVariable("movieId") int movieId) throws ParameterErrorException {
        return adminService.findAllComments(movieId);
    }
    /**
     * 删除讨论贴单条评论
     */
    @RequestMapping("delDiscussionitem/{discussionitemId}")
    private Map<String,Object> adminDelDiscussionitem(HttpSession session,@PathVariable("discussionitemId") int discussionitemId) throws ParameterErrorException {
        return adminService.delDiscussionitem(discussionitemId);
    }
    /**
     * 返回该讨论帖所有讨论内容
     */
    @RequestMapping("findDiscussion/{discussionId}")
    private Map<String,Object> findDiscussion(@PathVariable("discussionId") int discussionId) throws ParameterErrorException {
        return adminService.findDiscussion(discussionId);
    }

    /**
     * 删除讨论贴
     */
    @RequestMapping("delDiscussion/{discussionId}")
    private Map<String,Object> adminDelDiscussion(HttpSession session,@PathVariable("discussionId")int discussionId) throws ParameterErrorException {
        return adminService.delDiscussion(discussionId);
    }
    /**
     * 删除团约信息
     */
    @RequestMapping("delSpellgroups/{spellgroupsId}")
    private Map<String,Object> adminDelSpellgroups(HttpSession session,@PathVariable("spellgroupsId") int spellgroupsId) throws ParameterErrorException {
        return adminService.delSpellgroups(spellgroupsId);
    }
}
